package cn.csc.module.order.api.item;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.order.api.item.dto.OrderItemRespDTO;
import cn.csc.module.order.convert.item.OrderItemConvert;
import cn.csc.module.order.dal.dataobject.item.OrderItemDO;
import cn.csc.module.order.service.item.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/25 11:54
 */
@RestController
public class OrderItemApiImpl implements OrderItemApi {

    @Autowired
    private OrderItemService orderItemService;

    @Override
    public CommonResult<List<OrderItemRespDTO>> getByIds(List<BigInteger> ids) {
        List<OrderItemDO> itemList = orderItemService.getItemList(ids);
        return CommonResult.success(OrderItemConvert.INSTANCE.convertList03(itemList));
    }

    @Override
    public CommonResult<Map<BigInteger, List<OrderItemRespDTO>>> getByOrderIds(List<BigInteger> orderIds) {
        return CommonResult.success(orderItemService.getItemByOrderIds(orderIds));
    }

    @Override
    public CommonResult<List<OrderItemRespDTO>> getItemByOrderIds(List<BigInteger> orderIds) {
        return CommonResult.success(OrderItemConvert.INSTANCE.convertList03(orderItemService.getItemListByOrderId(orderIds)));
    }


}
